# 有两个日志文件a.txt/b.txt
# 两个日志中有重复的内容
# 取出只有在a.txt中存在的日志
# 读取所有的行，转为集合，求差集
# 最后转回列表

with open('logs/a.txt', mode='r') as fa:
    # 读取所有的行
    alist = fa.readlines()
    # print(alist)
with open('logs/b.txt', mode='r') as fb:
    blist = fb.readlines()
    # print(blist)
# 转为集合，计算差集
aset = set(alist)
bset = set(blist)
result = aset - bset
# print(result)
# 转为列表
res = list(result)
# print(res)
# 写入到一个文件中
with open('logs/c.txt', mode='w') as fc:
    fc.writelines(res)